//package com.zmn.plat.admin.controller.category.attribute;
//
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
//import org.apache.shiro.authz.annotation.RequiresPermissions;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.ModelAttribute;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.servlet.ModelAndView;
//
//import com.zmn.common.dictionary.GlobalDict;
//import com.zmn.plat.admin.controller.category.CategoryBaseController;
//import com.zmn.plat.model.entity.category.BaseCategory;
//import com.zmn.plat.model.entity.category.BaseCategoryAttribute;
//import com.zmn.plat.model.entity.category.BaseCategoryAttributeEnum;
//import com.zmn.plat.model.entity.category.BaseCategoryAttributeQuery;
//import com.zmn.plat.model.entity.channel.Channel;
//import com.zmn.plat.model.vo.category.BaseCategoryAttrVO;
//
///**
// * @author duanzuocai
// * @version v1.0
// * @since 2018/10/20 9:15
// */
//@Controller
//@RequestMapping("/categ/attr/")
//public class CategoryAttributeListController extends CategoryBaseController {
//
//    @RequiresPermissions("/categ/attr/list.action")
//    @RequestMapping(value = "list")
//    public ModelAndView list(@ModelAttribute BaseCategoryAttributeQuery query) {
//        ModelAndView mav = new ModelAndView("attribute/list");
//
//        Integer categId = query.getCategId();
//        if (categId == null) {
//            return mav;
//        }
//
//        BaseCategory categ = baseCategoryService.findByKey(categId);
//        BaseCategory parent = baseCategoryService.findByKey(categ.getParentId());
//        List<BaseCategoryAttrVO> items = baseCategoryAttributeService.listPageByQuery(query);
//        List<BaseCategoryAttributeEnum> attributeEnums = baseCategoryAttributeEnumService.listByCategoryId(categId);
//        Map<Integer, List<BaseCategoryAttributeEnum>> attributeEnumMap =
//            attributeEnums.stream().collect(Collectors.groupingBy(BaseCategoryAttributeEnum::getAttrId));
//        List<Channel> channelList = channelService.listTwoLevelChannel(null, null);
//
//        mav.addObject("channelList", channelList);
//        mav.addObject("vo", query);
//        mav.addObject("categ", categ);
//        mav.addObject("items", items);
//        mav.addObject("parent", parent);
//        mav.addObject("attributeEnumMap", attributeEnumMap);
//        return mav;
//    }
//
//    @RequiresPermissions("/categ/attr/detail.action")
//    @RequestMapping(value = "detail")
//    public ModelAndView detail(@RequestParam(value = "categId", defaultValue = "0") Integer categId,
//        @RequestParam(value = "attrId", defaultValue = "0") Integer attrId,
//        @RequestParam(value = "attrType", defaultValue = "0") Integer attrType) {
//        BaseCategoryAttribute attr;
//        if (attrId > 0) {
//            attr = baseCategoryAttributeService.findByKey(attrId);
//        } else {
//            attr = new BaseCategoryAttribute();
//            attr.setAttrType(attrType);
//        }
//
//        BaseCategory categ = baseCategoryService.findByKey(categId);
//
//        ModelAndView mav = new ModelAndView("attribute/detail");
//
//        if (Objects.nonNull(attr.getAttrType()) && Objects.equals(attr.getAttrType(), 2)) {
//            List<Channel> channelList = channelService.listTwoLevelChannel(null, null);
//            mav.addObject("channelList", channelList);
//        }
//
//        mav.addObject("statuses", GlobalDict.getStatusList(false));
//        mav.addObject("vo", attrId);
//        mav.addObject("attr", attr);
//        mav.addObject("categ", categ);
//        return mav;
//    }
//}
